package RSS.bean;


import lombok.Data;

import java.io.StringWriter;
import java.util.Date;

@Data
public class CommonInformationItem implements java.io.Serializable{
    private String title;    //item的title
    private String txtDate;    // 从xml中得到的是  String 日期
    private Date date;         //  转为  Date型

    private String link;   //item的link

    private StringBuffer  description;   //item的描述

    private String id;   //Item 的id

    private String source;   // RSS的源名称

    public void addDescription(   String txt){
        this.description.append( txt );
    }

    /**
     * 生成 此条 item 在磁盘上的文件名
     * @return    source_描述的hashcode.xml
     */
    public String getFileName(){
        StringWriter writer=new StringWriter( );
        writer.append(   source    );
        writer.append( "_");
        if(   description!=null) {
            writer.append(String.valueOf(description.hashCode()));
        }else{
            writer.append(    this.title.hashCode()+""  );
        }

        writer.append(".xml");
        return writer.toString();
    }


}
